/*
 * @Autor: taobo
 * @Date: 2020-06-10 09:43:46
 * @LastEditTime: 2020-06-16 14:50:48
 * @Description: 10进制转M进制
 */ 
#include <string>
#include <iostream>
#include <climits>
using namespace std;

string convertToBaseM(int num, int m){
    if(num == INT_MIN )
        return convertToBaseM(num/10,m) + to_string(-(num%10));
    if(num < 0) 
        return '-' + convertToBaseM(-num, m);
    if(num/m == 0) 
        return to_string(num);
    return convertToBaseM(num/m, m) + to_string(num%m);
}

int main()
{
    int num = INT_MIN;
    string ans = convertToBaseM(num, 8);
    cout <<"10 to 8: "<< ans <<endl;
    return 0;
}